<?php 
  session_start();
  ob_start();

  $host="localhost"; // Host name 

  $username="www"; // Mysql username 

  $SQLpassword="CRYURet4CNztqPWp"; // Mysql password 

  $db_name="androidtest"; // Database name 

  $tbl_name="member"; // Table name

  $salt="G4*UtR";// this put on to make the password more secure

  // Connect to server and select databse.

  mysql_connect("$host", "$username", "$SQLpassword")or die("cannot connect"); 

  mysql_select_db("$db_name")or die("cannot select DB");



  $username=$_POST['username'];

  

  if ($_POST['password'] == $_POST['repassword'])

  {

  $password=md5($salt.$_POST['password'].$salt);

  }


session_start();
  ?>
  
  
  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head>
<html xmlns="http://www.w3.org/1999/xhtml">
  <meta http-equiv="content-type" content="text/html; charset=utf-8">
  <title>Speed Settings</title>
  <link rel="stylesheet" type="text/css" href="CSS/style.css" />
</head>


<body>
  <div id="header">
  <h1><strong>This Android Website of Testing Stuff</strong></h1>
      
    <?
  if($_SESSION['loggedIn'] == true) { ?>  

    <div class="usermenu">
      <br>
      <br>
      <a href="/usersettings.php">User Settings</a>
      <br>
      <a href="/logout.php">Logout</a>
    </div>
    

    <div id="user">
  <? echo''.$_SESSION['username'].''; ?>
    </div>
  <? } ?>
  </div>

  <div id="bottomcurve">
  </div>

  <div class="menubar">

    <div class="empty">
      <a href="index.php">
      <img src="empty.gif">
      </a>
    </div>

    <div class="menuhome">
      Home
    </div>  

    <? if ($_SESSION['loggedIn'] == true){ ?>

      <div class="empty2">
        <a href="speedpage.php">
        <img src="empty.gif">
        </a>
      </div>

      <div class="menulogin">
        Speed
      </div>
      
<? }else{ ?> 
      <div class="empty2">
        <a href="login.php">
        <img src="empty.gif">
        </a>
      </div>

      <div class="menulogin">
        Login
      </div>
    <? }?>  

    <div class="empty3">
      <a href="register.php">
      <img src="empty.gif">
      </a>
    </div>

    <div class="menuregister">
    Register
    </div>

    <div class="empty4">
      <a href="credits.php">
      <img src="empty.gif">
      </a>
    </div>

    <div class="menucredits">
    Credits
    </div>
  </div>

 <section>
     <div id= "speedsettings">
	 
	 <?PHP


if (isset($_POST['formSubmit'])) {

	$selected_radio = $_POST['speed'];
	
		if ($selected_radio == '0') {
			$speed = 0;
				$sql2="UPDATE `$tbl_name` SET speed='$speed' WHERE username='$username' AND password='$password'";
				$result2 = mysql_query($sql2);

		}
		if ($selected_radio == '1') {
			$speed = 1;
				$sql2="UPDATE `$tbl_name` SET speed='$speed' WHERE username='$username' AND password='$password'";
				$result2 = mysql_query($sql2);
		}
		if ($selected_radio == '2') {
			$speed = 2;
				$sql2="UPDATE `$tbl_name` SET speed='$speed' WHERE username='$username' AND password='$password'";
				$result2 = mysql_query($sql2);
		}
		if ($selected_radio == '3') {
			$speed = 3;
				$sql2="UPDATE `$tbl_name` SET speed='$speed' WHERE username='$username' AND password='$password'";
				$result2 = mysql_query($sql2);
		}
}

?>
	 
		<form NAME ="form1" METHOD ="POST" action="speedpage.php">
		
      <input type='radio' name='speed' value='0'/>off&nbsp  &nbsp<br>
      <input type='radio' name='speed' value='1'/>slow&nbsp &nbsp<br>
      <input type='radio' name='speed' value='2'/>medium&nbsp &nbsp<br>
      <input type='radio' name='speed' value='3'/>high&nbsp &nbsp<br>
     </form>
<form method="post" action="speedpage.php">
		<label for='formCountries[]'>Select a speed:<?echo $speed;?></label><br>
	<select name="categoryID">
	
	
	
	
<?php 
$sql="SELECT id, username FROM member";
$result =mysql_query($sql);
while ($data=mysql_fetch_assoc($result)){
?>
<option value ='<?php echo $data['id'] ?>' ><?php echo $data['username'] ?> </option>
<?php } 
$_session['selectspeedid'] = $data['id']; 
$_session['selectspeedUN'] = $data['username'];?>

</select>


		<input type="submit" name="formSubmit" value="Submit" >
</form>
</div>
    </section>


  

  
 
<body>
</body>
</html>